package com.lt.member;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import code.lewdy.util.FormatUtil;

@Entity
@Table
public class Member{
    
	
	private int id;
	private int isLock;  //0-未锁定|1-已锁定（不能登录）
	private int isDatumLock;  //0-未锁定|1-已锁定,是否锁定资料，锁定则前台账户不能修改账户银行资料，只能由后台管理员修改
	private String username;
	private int fatherId; //上级ID
	private String topName; //上级用户名
	private String password;
    private String securityPassword; // security password
	private String email;
	private String tel;
    private double balance;   // left money //可用资金
    private double totalAmount; //总资金
    private double freezeAmount; //冻结资金
	private int accountType; // Parameters -1:root | 0 :normal | 1:agency
    private int questionId1;   //密保验证问题1
    private int questionId2;
    private int questionId3;
    private String answer1; //密保验证问题答案1
    private String answer2;
    private String answer3;
    private String bankName;
    private String bankNo; //银行账号
    private String bankAccountName; //银行户名
	private float returnPoint; //返点
	private float bdReturnPoint; //不定位返点
    private Date registerDate;
    private Date lastLoginDate;
    private int isOnline; //是否在线 0-未|1-在线
    
    
//    /**盈亏总计
//	 * @param uid
//	 * @return
//	 */
//    @Transient
//	public Double getWinAmount(){
//		return MemberService.getWinAmount(this.getId());
//	}
//    
//    /**获取返点总额
//	 * @param uid
//	 * @return
//	 */
//    @Transient
//	public Double getTotalReturnAmount(){
//		return MemberService.getTotalReturnAmount(this.getId());
//	}
//    
//    /**中奖总额
//	 * @param uid
//	 * @return
//	 */
//    @Transient
//	public Double getTotalReward(){
//		return MemberService.getTotalReward(this.getId());
//	}
    
    /**是否在线
     * @return
     */
    @Transient
    public int getIsSessionOnline(){
    	return MemberService.getIsSessionOnline(this.id);
    }

    /**获取下级会员数量
     * @return
     */
    @Transient
    public int getLowerMemberCount(){
    	return MemberService.getLowerMemberCount(this.getId());
    }
    
//    /**获取投注总额
//     * @return
//     */
//    @Transient
//    public Double getBetTotalAmount(){
//    	return MemberService.getBetTotalAmount(this.getId());
//    }
    
    @Id
    @GeneratedValue
    public int getId()
    {
        return id;
    }
    public void setId(int id)
    {
        this.id = id;
    }
    public int getAccountType()
    {
        return accountType;
    }
    public void setAccountType(int accountType)
    {
        this.accountType = accountType;
    }
    public double getBalance()
    {
    	balance = FormatUtil.formatDecimal(balance, 2);
        return balance;
    }
    public void setBalance(double balance)
    {
        this.balance = balance;
    }
    @Column(length=30)
    public String getEmail()
    {
        return email;
    }
    public void setEmail(String email)
    {
        this.email = email;
    }
    @Column(length=50)
    public String getPassword()
    {
        return password;
    }
    public void setPassword(String password)
    {
        this.password = password;
    }
    @Column(length=13)
    public String getTel()
    {
        return tel;
    }
    public void setTel(String tel)
    {
        this.tel = tel;
    }
    @Column(length=30, nullable = false, unique = true)
    public String getUsername()
    {
        return username;
    }
    public void setUsername(String username)
    {
        this.username = username;
    }
    @Column(length=30)
    public String getAnswer1()
    {
        return answer1;
    }
    public void setAnswer1(String answer1)
    {
        this.answer1 = answer1;
    }
    @Column(length=30)
    public String getAnswer2()
    {
        return answer2;
    }
    public void setAnswer2(String answer2)
    {
        this.answer2 = answer2;
    }
    public String getAnswer3()
    {
        return answer3;
    }
    @Column(length=30)
    public void setAnswer3(String answer3)
    {
        this.answer3 = answer3;
    }
    public int getQuestionId1()
    {
        return questionId1;
    }
    public void setQuestionId1(int questionId1)
    {
        this.questionId1 = questionId1;
    }
    public int getQuestionId2()
    {
        return questionId2;
    }
    public void setQuestionId2(int questionId2)
    {
        this.questionId2 = questionId2;
    }
    public int getQuestionId3()
    {
        return questionId3;
    }
    public void setQuestionId3(int questionId3)
    {
        this.questionId3 = questionId3;
    }
    @Column(length=50)
    public String getSecurityPassword()
    {
        return securityPassword;
    }
    public void setSecurityPassword(String securityPassword)
    {
        this.securityPassword = securityPassword;
    }
    @Column(length=30)
    public String getBankName()
    {
        return bankName;
    }
    public void setBankName(String bankName)
    {
        this.bankName = bankName;
    }
    @Column(length=50)
    public String getBankNo()
    {
        return bankNo;
    }
    public void setBankNo(String bankNo)
    {
        this.bankNo = bankNo;
    }
	public void setReturnPoint(float returnPoint) {
		this.returnPoint = returnPoint;
	}
	public float getReturnPoint() {
		return returnPoint;
	}
	public void setFatherId(int fatherId) {
		this.fatherId = fatherId;
	}
	public int getFatherId() {
		return fatherId;
	}
    @Temporal(TemporalType.TIMESTAMP)
    public Date getLastLoginDate()
    {
        return lastLoginDate;
    }
    public void setLastLoginDate(Date lastLoginDate)
    {
        this.lastLoginDate = lastLoginDate;
    }
    @Temporal(TemporalType.TIMESTAMP)
    public Date getRegisterDate()
    {
        return registerDate;
    }
    public void setRegisterDate(Date registerDate)
    {
        this.registerDate = registerDate;
    }
	public String getTopName() {
		return topName;
	}
	public void setTopName(String topName) {
		this.topName = topName;
	}
	public double getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(double totalAmount) {
		this.totalAmount = totalAmount;
	}
	public double getFreezeAmount() {
		return freezeAmount;
	}
	public void setFreezeAmount(double freezeAmount) {
		this.freezeAmount = freezeAmount;
	}
	public void setIsLock(int isLock) {
		this.isLock = isLock;
	}
	public int getIsLock() {
		return isLock;
	}
	@Column(length=30)
	public String getBankAccountName() {
		return bankAccountName;
	}
	public void setBankAccountName(String bankAccountName) {
		this.bankAccountName = bankAccountName;
	}
	public void setIsDatumLock(int isDatumLock) {
		this.isDatumLock = isDatumLock;
	}
	public int getIsDatumLock() {
		return isDatumLock;
	}
	public void setBdReturnPoint(float bdReturnPoint) {
		this.bdReturnPoint = bdReturnPoint;
	}
	public float getBdReturnPoint() {
		return bdReturnPoint;
	}
	public void setIsOnline(int isOnline) {
		this.isOnline = isOnline;
	}
	public int getIsOnline() {
		//isOnline = MemberService.getIsOnline(this.getId());
		return isOnline;
	}
}
